<?php
namespace app\admin\model;
use app\common\model\BaseModel;
class Order extends BaseModel
{
	public function getProductIdAttr($val){
		$sandConf=require CONF_PATH.'sand/config.php';
		return $sandConf['product'][$val];
	}
	public function getTranTimeAttr($val){
		
		return date('Y/m/d H:i:s',strtotime($val));
	}

	public function getStatusAttr($val){
		switch ($val) {
			case '0':
				return '成功';
				break;
			case '1':
				return '失败';
				break;
			case '2':
				return '处理中';
			default:
				return '异常';
				break;
		}
	}
	public function saveByRes($res){
		$order=[
            'status'=>$res->resultFlag,
            'sand_serial'=>$res->sandSerial,
            'tran_date'=>$res->tranDate
        ];
        return $this->save($order,['order_code'=>$res->orderCode])?true:false;
	}
	
}